#ifndef _A_GAME__COMM__LIMIT_RESOURCES_MANAGER_H_
#define _A_GAME__COMM__LIMIT_RESOURCES_MANAGER_H_

#include <stdint.h>

#ifdef __cplusplus
extern "C" {
#endif

#define INVALIDATE_ID ((uint64_t)-1)
typedef uint64_t resid_t;

struct resources_opt {
	void * (*alloc)(void * manager_ctx);
	void (*free)(void * res, void * manager_ctx);

	int (*init)(void * res, void * resources_ctx);
	void (*destory)(void * res, void * resources_ctx);
};

resid_t create_resources_manager(int max, 
		struct resources_opt * opt, 
		void * ctx);

void destory_resources_manager(resid_t manager_id);

resid_t get_free_resource(resid_t manager_id, void * ctx);
void release_resources(resid_t manager_id, resid_t resource_id);

void * get_resources(resid_t manager_id, resid_t resources_id);
void * set_resources(resid_t manager_id, resid_t resources_id, void * res);

void * get_resources_data(resid_t manager_id, resid_t resources_id);
void * set_resources_data(resid_t manager_id, resid_t resources_id, void * ctx);

#ifdef __cplusplus
}
#endif

#endif
